package com.guiji.text2video.system.api.factory;

import com.guiji.text2video.system.api.RemoteNLPService;
import com.guiji.text2video.system.api.domain.FastVideoSimilarityRequest;
import feign.Response;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @ClassName RemoteNLPFallbackFactory
 * @Description TODO
 * @Author 钟维澎（四月）
 * @Date 2021/6/3 14:12
 * @Version 1.0
 */
@Component
public class RemoteNLPFallbackFactory implements FallbackFactory<RemoteNLPService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteNLPFallbackFactory.class);

    @Override
    public RemoteNLPService create(Throwable throwable) {
        log.error("NLP服务调用失败:{}", throwable.getMessage());
        return new RemoteNLPService() {
            @Override
            public Response nlp(String nlp) {
                return null;
            }

            @Override
            public Response similarity(FastVideoSimilarityRequest request) {
                return null;
            }
        };
    }
}
